const utils = require('j7/utils');
const BaseModel = require('./basemodel');

class Log extends BaseModel {

  async add(params) {
    const nowTime = utils.getUtcTime();
    const fields = [
        ['type', params['type']],
        ['sub_type', params['sub_type']],
        ['net_id', params['net_id']],
        ['createtime', nowTime],
        ['modifytime', nowTime],
    ];
    for (i = 1; i <= 4; ++i) {
      const key = 'param' + i;
      if (utils.hasKey(params, key)) {
        fields.push([key, params[key]]);
      }
    }
    await this.getSession().bcEventConn
    (
      'insert',
      't_log',
      fields
    );
  }

}

module.exports = Log;
